/*
 * CopyRright (c) laolema.cn: 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.epfresh.api.utils;

import android.content.Context;

public class L {


    public static boolean D;

    public static boolean I;


    public static boolean E;

    public static boolean V;


    public static boolean W;


    public static void debug(boolean d) {
        D = d;
    }


    public static void info(boolean i) {
        I = i;
    }

    public static void error(boolean e) {
        E = e;
    }

    public static void warn(boolean w) {
        W = w;
    }

    public static void setLog(boolean d, boolean i, boolean e, boolean w) {
        D = d;
        I = i;
        E = e;
        W = w;
    }

    public static void openAll() {
        D = true;
        I = true;
        V = true;
        E = true;
        W = true;
    }

    public static void closeAll() {
        D = false;
        I = false;
        V = false;
        E = false;
        W = false;
    }

    /**
     * @param tag Used to identify the source of a android.util.Log message. It usually
     *            identifies the class or activity where the android.util.Log call occurs.
     * @param msg The message you would like android.util.Logged.
     */
    public static void d(String tag, String msg) {
        if (D)
            android.util.Log.d(tag, msg);

    }

    /**
     * @param context Used to identify the source of a android.util.Log message.
     * @param msg     The message you would like android.util.Logged.
     */
    public static void d(Context context, String msg) {
        if (D) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.d(tag, msg);
        }

    }

    public static void d(Class<?> clazz, String msg) {
        if (D) {
            String tag = clazz.getSimpleName();
            android.util.Log.d(tag, msg);
        }

    }

    public static void d(String tag, String msg, Throwable tr) {
        if (D)
            android.util.Log.d(tag, msg, tr);
    }

    public static void d(Context context, String msg, Throwable tr) {
        if (D) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.d(tag, msg, tr);
        }
    }

    public static void d(Class<?> clazz, String msg, Throwable tr) {
        if (D) {
            String tag = clazz.getSimpleName();
            android.util.Log.d(tag, msg, tr);
        }
    }


    public static void i(String tag, String msg) {
        if (I)
            android.util.Log.i(tag, msg);

    }


    public static void i(Context context, String msg) {
        if (I) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.i(tag, msg);
        }

    }


    public static void i(Class<?> clazz, String msg) {
        if (I) {
            String tag = clazz.getSimpleName();
            android.util.Log.i(tag, msg);
        }

    }


    public static void i(String tag, String msg, Throwable tr) {
        if (I)
            android.util.Log.i(tag, msg, tr);
    }


    public static void i(Context context, String msg, Throwable tr) {
        if (I) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.i(tag, msg, tr);
        }
    }

    public static void i(Class<?> clazz, String msg, Throwable tr) {
        if (I) {
            String tag = clazz.getSimpleName();
            android.util.Log.d(tag, msg, tr);
        }
    }


    public static void v(String tag, String msg) {
        if (V)
            android.util.Log.v(tag, msg);

    }


    public static void v(Context context, String msg) {
        if (V) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.v(tag, msg);
        }

    }


    public static void v(Class<?> clazz, String msg) {
        if (V) {
            String tag = clazz.getSimpleName();
            android.util.Log.v(tag, msg);
        }

    }


    public static void v(String tag, String msg, Throwable tr) {
        if (V)
            android.util.Log.v(tag, msg, tr);
    }


    public static void v(Context context, String msg, Throwable tr) {
        if (V) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.i(tag, msg, tr);
        }
    }

    public static void v(Class<?> clazz, String msg, Throwable tr) {
        if (V) {
            String tag = clazz.getSimpleName();
            android.util.Log.d(tag, msg, tr);
        }
    }

    public static void e(String tag, String msg) {
        if (E)
            android.util.Log.e(tag, msg);

    }

    public static void e(Context context, String msg) {
        if (E) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.e(tag, msg);
        }

    }

    public static void e(Class<?> clazz, String msg) {
        if (E) {
            String tag = clazz.getSimpleName();
            android.util.Log.e(tag, msg);
        }

    }

    public static void e(String tag, String msg, Throwable tr) {
        if (E)
            android.util.Log.e(tag, msg, tr);
    }

    public static void e(Context context, String msg, Throwable tr) {
        if (E) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.e(tag, msg, tr);
        }
    }

    public static void e(Class<?> clazz, String msg, Throwable tr) {
        if (E) {
            String tag = clazz.getSimpleName();
            android.util.Log.e(tag, msg, tr);
        }
    }

    public static void w(String tag, String msg) {
        if (W)
            android.util.Log.w(tag, msg);

    }


    public static void w(Context context, String msg) {
        if (W) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.w(tag, msg);
        }

    }


    public static void w(Class<?> clazz, String msg) {
        if (W) {
            String tag = clazz.getSimpleName();
            android.util.Log.w(tag, msg);
        }

    }

    public static void w(String tag, String msg, Throwable tr) {
        if (W)
            android.util.Log.w(tag, msg, tr);
    }


    public static void w(Context context, String msg, Throwable tr) {
        if (W) {
            String tag = context.getClass().getSimpleName();
            android.util.Log.w(tag, msg, tr);
        }
    }


    public static void w(Class<?> clazz, String msg, Throwable tr) {
        if (W) {
            String tag = clazz.getSimpleName();
            android.util.Log.w(tag, msg, tr);
        }
    }

    public static long lastTime;

    public static void timeMills() {
        long currentTime = System.currentTimeMillis();
        L.d("time", "timeMills:" + currentTime);
        L.d("time", "timeMillsDff:" + (currentTime - lastTime));
        lastTime = currentTime;
    }



}
